<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .animate{
            width: 100px;
            height: 100px;
            background: #cccccc;
            transition: width 3s;   
        }
        .fade-enter-active,
        .fade-leave-active{
            transition: opacity 3s;
        }
        .fade-enter,
        .fade-leave-to{
            opacity: 0;
        }
    </style>
</head>
<body>
    <div id="app">
        <button @click="show= !show">展示</button>
        <transition name="fade">
            <demo v-if="show"></demo>
        </transition>
    </div>
   

    <script src="./vue.js"></script>
    <script>
        Vue.component("demo",{
            template: `
                <div class="animate"></div>
            `
        })

        let vm = new Vue({
            el: '#app',
            data: {
                show: false
            }
        })
    </script>
</body>
</html>